-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix false positive for positional-only-arguments-expected
#8556
Fix false positive for positional-only-arguments-expected
#8556
Conversation
…function contains both a positional-only parameter that has a default value, and ``**kwargs``. Closes #8555
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8556 +/- ##
=======================================
Coverage 95.90% 95.91%
=======================================
Files 174 174
Lines 18353 18370 +17
=======================================
+ Hits 17602 17619 +17
Misses 751 751
|
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 6e4d89f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice edge case! I find this profoundly weird, and honestly, after reading PEP 570 a couple times, I feel like this could even be reported to CPython as a bug. But even if it's not a bug, it should be a pylint warning on the function def, not a pylint error on the call.
However, I did find this regression, based on the example in PEP 570 ("Semantic Corner Case"). Would you be able to fix and add a test case?
def foo(name, /, **kwds):
return 'name' in kwds
foo(name=3)
Gives:
TypeError: foo() missing 1 required positional argument: 'name'
main
emits:
corner.py:4:0: E3102: `foo()` got some positional-only arguments passed as keyword arguments: 'name' (positional-only-arguments-expected)
PR emits nothing.
Opened #8558 to track emitting a different message for the original reported case. |
I don't think this is a regression. The TypeError you've identified is def foo(name, /, **kwds):
print(kwds)
return 'name' in kwds
>>> foo(1, name=3)
>>> {'name': 3} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, makes sense.
…function contains both a positional-only parameter that has a default value, and ``**kwargs``. (#8556) (#8560) (cherry picked from commit db17860) Co-authored-by: Mark Byrne <[email protected]>
Type of Changes
Description
Fix false positive for
positional-only-arguments-expected
when afunction contains both a positional-only parameter that has a default value, and
**kwargs
.Closes #8555